/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package newkfp;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author $alama
 */
@Stateless
public class FactoryFacade extends AbstractFacade<Factory> {

    @PersistenceContext(unitName = "KFPNEWPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public FactoryFacade() {
        super(Factory.class);
    }

    public  Factory find(String factoryName, Country idcountry) {
        try {
            Query query = em.createNamedQuery("Factory.findByFactoryNameAndIDCountry");
            query.setParameter("factoryName", factoryName);
            query.setParameter("idcountry", idcountry);
            return (Factory)query.getResultList().get(0);
        } catch (Exception e) {
            return null;
        }

    }
}
